package cn.tedu.rabbitmqboot.m2;


/*
 * 消费者自动启动,注册成为消费者
 * 自动开启监听队列中的消息
 * 不需要手动调用
 * @RabbitListener(queues = "helloworld")
 *   1. 在类上注解,需要 @RabbitHandler配合指定处理消息的方法
 *   2. 直接加载在方法上
 * */

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class Consumer {
    @RabbitListener(queues = "task_queue")
    public void receive1(String msg) {
        System.out.println("消费者1收到: " + msg);
    }

    @RabbitListener(queues = "task_queue")
    public void receive2(String msg) {
        System.out.println("消费者2收到: " + msg);
    }


}
